package com.jacobson.huobi.mvp.presenter

import com.jacobson.core.di.annotation.ActivityScope
import com.jacobson.core.mvp.BasePresenter
import com.jacobson.huobi.common.expansion.applySchedulersIoMain
import com.jacobson.huobi.common.expansion.onResponseResult
import com.jacobson.huobi.mvp.contract.MeContract
import javax.inject.Inject

@ActivityScope
class MePresenter @Inject constructor(
    view: MeContract.View,
    model: MeContract.Model
) : BasePresenter<MeContract.View, MeContract.Model>(view, model), MeContract.Presenter {

    override fun refreshToken() {
        model.refreshToken()
            .applySchedulersIoMain()
            .onResponseResult(view) { resp ->
                view?.onRefreshTokenResultResp(resp)
            }

    }

    override fun loadNoticeLatest() {
        model.loadNoticeLatest()
            .applySchedulersIoMain()
            .onResponseResult(view) { resp ->
                view?.onLoadNoticeLatestResultResp(resp)
            }
    }


    override fun loadUpdateInfo( ){
        model.loadUpdateInfo()
            .applySchedulersIoMain()
            .onResponseResult(view){
                resp -> view?.showUpdateDialog(resp)
            }
    }

}
